// pages/order/order.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userId: 1,
    token: '',
    orderList1:[
      {
        id: '202105170322',
        restaurantName: "传世排骨汤饭",
        pic:"https://z3.ax1x.com/2021/05/12/gw15o6.jpg",
        state: "订单取消",
        price: "12",
        date: "2017-07-14",
        time: "12:29:12",
        howToDistribute: "商家"
      },
      {
        id: '202105170323',
        restaurantName: "传世排骨汤饭",
        pic:"https://z3.ax1x.com/2021/05/12/gw15o6.jpg",
        state: "订单派送中",
        price: "12",
        date: "2017-07-14",
        time: "12:29:12",
        howToDistribute: "商家"
      },
      {
        id: '202105170324',
        restaurantName: "传世排骨汤饭",
        pic:"https://z3.ax1x.com/2021/05/12/gw15o6.jpg",
        state: "订单完成",
        price: "12",
        date: "2017-07-14",
        time: "12:29:12",
        howToDistribute: "商家"
      }
    ]
  },

  detail: function(e){
    var orderId = e.currentTarget.dataset.notice_id;
    wx.navigateTo({
      url: '../order/detail/detail?orderId='+orderId,
    })  
  },
  comment: function(e){
    var orderId = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '../order/comment/comment?orderId='+orderId,
    })  
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.initdata();
  
  },

  initdata: function(){
    var that = this;
    that.data.token = app.getToken()
    console.log(that.data.token)
    //网络请求获取账单数据
    wx.request({
      url: 'http://localhost:8080/community/ec/orderlist',
      method:'GET',
      header:{
        'content-type': 'application/json',
        'Authorization':  that.data.token
      },
      success:function(res){
        // console.log("userInfo" + JSON.stringify(res))
        console.log(res.data);
        that.setData({
          orderList: res.data.data
        });
      },
    }) 

},
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})